<?php
/**
 * The template for displaying all pages.
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */
get_header();
?>
<script type="text/javascript">
    $(document).ready(function() {
        $('.logo_thuonghieu_container').jcarousel({
            auto: 2,
            wrap: 'circular',
        });
    })
</script>
<!--/#menu2-->
<div class="grid1000">
    <div class="slider"><?php
        if (function_exists('show_nivo_slider')) {
            show_nivo_slider();
        }
        ?></div>
    <div class="left">

        <?php wp_nav_menu(array('theme_location' => 'menu_main', 'menu_class' => 'box_title mainmenu', 'container_class' => '')); ?>
        <ul class="group_logo">
            <?php
            global $post;

            $args = array('posts_per_page' => 6, 'offset' => 0, 'category' => 6);

            $myposts = get_posts($args);

            foreach ($myposts as $post) : setup_postdata($post);
                ?>
                <li>
                    <?php
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('full');
                    }
                    ?>
                </li>
            <?php endforeach; ?>

        </ul>
        <div class="clear"></div>
    </div>
    <!--/.left-->
    <div class="right hotro">
        <h2 class="box_title">HỖ TRỢ TRỰC TUYẾN</h2>
        <div class="body">
            <p style="margin-top:0; padding-top:20px;">
                <span class="img"><a href="ymsgr:sendim?hotrottol"><img src="images/icon_yahoo.png" alt="" /></a></span>
                <span>Kinh doanh 1<br />0904.525.529</span>
            </p>
            <div class="border_bottom clear"></div>
            <p>
                <span class="img"><a href="skype:hotrottol?chat"><img src="images/icon_skype.png" alt="" /></a></span>
                <span>Kinh doanh 1<br />0904.525.529</span>
            </p>
            <div class="border_bottom clear"></div>
            <p class="online">

                <span style="color:#fff; font-weight:bold; font-size:14px; margin-top:8px;">
                    Đặt hàng online
                </span>
                <span style="font-weight: bold; color:#ffb70a; font-size:22px;">
                    04.6328.5005 
                    <br />0906.265.165
                </span>
                <span style="font-size:12px;">
                    Email: contact@vnad.com.vn
                </span>

            </p>
            <div class="clear"></div>

        </div><!--/.body-->
    </div><!--/.right-->
    <div class="clear"></div>
    <div class="baiviet">
        <?php
        $args = array('posts_per_page' => 4, 'offset' => 0, 'category' => 8);

        $myposts = get_posts($args);

        foreach ($myposts as $post) : setup_postdata($post);
            global $more;
            $more = 0;
            ?>

            <div class="item">
                <h2><?php the_title() ?></h2>
                <div> <?php
                    if (has_post_thumbnail()) {
                        the_post_thumbnail();
                    }
                    ?>
                    <?php the_content(''); ?>
                    <div class="xemchitiet"><a href="<?php the_permalink() ?>">Xem chi tiết</a></div>
                </div>
            </div>

        <?php endforeach; ?>


        <div class="clear"></div>
    </div>
    <!--/.baiviet-->
    <div class="bn1000x100">
        <?php
        global $wpdb;
        $banner1000x100 = $wpdb->get_row($wpdb->prepare("select * from  $wpdb->posts where post_title='Banner1000x100' AND post_type='post'"));
        $banner1000x100_image = wp_get_attachment_url(get_post_thumbnail_id($banner1000x100->ID));
        ?>
        <img src="<?php echo $banner1000x100_image ?>"/>
    </div>
    <div class="logo_thuonghieu">
        <h2>Logo Creative</h2>
        <div class="logo_thuonghieu_container">
            <ul>
                <?php
                $args = array('posts_per_page' => 8, 'offset' => 0, 'category' => 12);
                $myposts = get_posts($args);
                foreach ($myposts as $post) : setup_postdata($post);
                    if (has_post_thumbnail()) {
                        ?>
                        <li>
                            <?php
                            the_post_thumbnail('medium');
                            ?>
                        </li>
                        <?php
                    }
                endforeach;
                ?>
            </ul>    
        </div>
    </div>
    <!--/.logo_thuonghieu-->

    <div class="logo_thuonghieu">
        <h2>Thương hiệu nổi tiếng</h2>
        <div> 
            <?php
            $args = array('posts_per_page' => 8, 'offset' => 0, 'category' => 13);
            $myposts = get_posts($args);
            foreach ($myposts as $post) : setup_postdata($post);
                if (has_post_thumbnail()) {
                    the_post_thumbnail('medium');
                }
            endforeach;
            ?>
        </div>
    </div>
    <!--/.logo_thuonghieu-->
    <div class="clear"></div>
    <?php
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $args = array('posts_per_page' => -1, 'offset' => 0, 'category' => 14);
    $Category5 = get_posts($args);
    $args = array('posts_per_page' => -1, 'offset' => 0, 'category' => 16);
    $Category6 = get_posts($args);
    $args = array('posts_per_page' => -1, 'offset' => 0, 'category' => 17);
    $Category7 = get_posts($args);
    ?>
    <div id="kienthuc_container">

        <ul class="kienthuc_title">
            <li>
                <a href="#thiet-ke">
                    <h2 class="kienthuc_title_active">
                        <span>
                            Kiến thức Thiết kế
                            </spankế>
                    </h2>
                </a>
            </li>
            <li>
                <a href="#thuong-hieu">
                    <h2>
                        <span>
                            Kiến thức Thương hiệu
                            </spankế>
                    </h2>
                </a>
            </li>
            <li>
                <a href="#quang-cao">
                    <h2>
                        <span>
                            Kiến thức Quảng cáo
                            </spankế>
                    </h2>
                </a>
            </li>
        </ul>

        <script type="text/javascript">
            $(function() {
                $(".kienthuc_title h2").click(function() {
                    $(".kienthuc_title h2").removeClass('kienthuc_title_active');
                    $(this).addClass('kienthuc_title_active');
                })
                $("#kienthuc_container").tabs({hide: {effect: "fade", duration: 500}, show: {effect: "fade", duration: 500}});
            });
        </script>
        <div class="left kienthuc">
            <div class="left-container-content" id="thiet-ke"> 
                <script type="text/javascript">
                    function changePage(id, CurrentPage, MaxPage) {
                        $('.' + id + '-page-container').hide();
                        $('#' + id + '-page' + CurrentPage).fadeIn('medium');
                        if (CurrentPage > 1) {
                            $('.prev-container').fadeIn('medium');
                        }
                        else {
                            $('.prev-container').fadeOut('medium');
                        }
                        if (CurrentPage >= MaxPage) {
                            $('.next-container').fadeOut('medium');
                        }
                        else {
                            $('.next-container').fadeIn('medium');
                        }
                        $("#pagine-" + id).find('.page-container').find('span').removeClass('current-page');
                        $("#pagine-" + id).find('.page-container').find('span').each(function() {
                            if ($(this).text() == CurrentPage) {
                                $(this).addClass('current-page');
                                return;
                            }
                        });
                    }
                    var CurrentPageThietKe = 1;
                    var CurrentPageThuongHieu = 1;
                    var CurrentPageQuangCao = 1;
                    $(document).ready(function() {
                        $('.prev-container').hide();
                        $('.next-container').show();
                        $("#pagine-thiet-ke").find('.page-container').find('span').click(function() {
                            CurrentPageThietKe = $(this).text();
                            changePage('thiet-ke', CurrentPageThietKe, CountPageThietKe);
                        })
                        $("#pagine-thuong-hieu").find('.page-container').find('span').click(function() {
                            CurrentPageThuongHieu = $(this).text();
                            changePage('thuong-hieu', CurrentPageThuongHieu, CountPageThuongHieu);
                        })
                        $("#pagine-quang-cao").find('.page-container').find('span').click(function() {
                            CurrentPageQuangCao = $(this).text();
                            changePage('quang-cao', CurrentPageQuangCao, CountPageQuangCao);
                        })
                    })
                </script>
                <?php
                $CountPost = 0;
                $CountPage = 1;
                $CurrentPage = 1;
                $CountTotalPost = 0;
                foreach ($Category5 as $post) : setup_postdata($post);
                    global $more;
                    $more = 0;
                    if ($CountPost === 0) {
                        ?>
                        <div class="thiet-ke-page-container"style='<?php if ($CountPage !== 1) echo 'display:none' ?>'id="thiet-ke-page<?php echo $CountPage; ?>">
                            <?php
                        }
                        ?>
                        <div class="content_container">
                            <?php
                            if ($CountPost === 0) {
                                ?>
                                <div class="thumbnail-content">
                                    <?php
                                    if (has_post_thumbnail()) {
                                        the_post_thumbnail();
                                    }
                                    ?>
                                    <span class="content-title"><p><?php the_title() ?></p></span>
                                    <br/>
                                    <?php the_content(''); ?>
                                    <div class="xemchitiet two"><a href="<?php the_permalink() ?>">Xem chi tiết</a></div>
                                </div>
                                <?php
                            } else {
                                ?>
                                <div class="ex-content">
                                    <ul class="more_link">
                                        <li>
                                            <span><a href="<?php the_permalink() ?>"><span class="content-title"><?php the_title() ?></span></a></span>
                                        </li>
                                    </ul>
                                </div>
                                <?php
                            }
                            ?>
                        </div>
                        <?php
                        $CountPost++;
                        if ($CountPost > 2 || $CountTotalPost >= count($Category5) - 1) {
                            ?>
                        </div>
                        <?php
                        $CountPost = 0;
                        $CountPage++;
                    }
                    $CountTotalPost++;
                endforeach;
                ?>
                <script type="text/javascript">
                    var CountPageThietKe = <?php echo ($CountPage - 1); ?>;
                </script>
                <div class="pagine_container" id="pagine-thiet-ke">
                    <span style="cursor: pointer"class="prev-container">
                        <span class="first"onclick="CurrentPageThietKe = 1;
                        changePage('thiet-ke', CurrentPageThietKe, CountPageThietKe);">Trang đầu</span>
                        <span class="pre"onclick="CurrentPageThietKe--;
                        changePage('thiet-ke', CurrentPageThietKe, CountPageThietKe);">Trước</span>
                    </span>
                    <span class="page-container">
                        <?php
                        for ($i = 1; $i < $CountPage; $i++) {
                            ?>
                            <span class="<?php if ($i === 1) echo 'current-page' ?> number"style="cursor: pointer"><?php echo $i ?></span>
                            <?php
                        }
                        ?>
                    </span>
                    <span style="cursor: pointer"class="next-container">
                        <span class="next" onclick="CurrentPageThietKe++;
                        changePage('thiet-ke', CurrentPageThietKe, CountPageThietKe);">Sau</span>
                        <span class="last"onclick="CurrentPageThietKe = CountPageThietKe;
                        changePage('thiet-ke', CurrentPageThietKe, CountPageThietKe);">Trang cuối</span>
                    </span>
                </div>
            </div>
            <div class="left-container-content" id="thuong-hieu"> 

                <?php
                $CountPost = 0;
                $CountPage = 1;
                $CurrentPage = 1;
                $CountTotalPost = 0;
                foreach ($Category6 as $post) : setup_postdata($post);
                    global $more;
                    $more = 0;
                    if ($CountPost === 0) {
                        ?>
                        <div class="thuong-hieu-page-container"style='<?php if ($CountPage !== 1) echo 'display:none' ?>'id="thuong-hieu-page<?php echo $CountPage; ?>">
                            <?php
                        }
                        ?>
                        <div class="content_container">
                            <?php
                            if ($CountPost === 0) {
                                ?>
                                <div class="thumbnail-content">
                                    <?php
                                    if (has_post_thumbnail()) {
                                        the_post_thumbnail();
                                    }
                                    ?>
                                    <span class="content-title"><p><?php the_title() ?></p></span>
                                    <br/>
                                    <?php the_content(''); ?>
                                    <div class="xemchitiet two"><a href="<?php the_permalink() ?>">Xem chi tiết</a></div>
                                </div>
                                <?php
                            } else {
                                ?>
                                <div class="ex-content">
                                    <ul class="more_link">
                                        <li>
                                            <span><a href="<?php the_permalink() ?>"><span class="content-title"><?php the_title() ?></span></a></span>
                                        </li>
                                    </ul>
                                </div>
                                <?php
                            }
                            ?>
                        </div>
                        <?php
                        $CountPost++;
                        if ($CountPost > 2 || $CountTotalPost >= count($Category6) - 1) {
                            ?>
                        </div>
                        <?php
                        $CountPost = 0;
                        $CountPage++;
                    }
                    $CountTotalPost++;
                endforeach;
                ?>
                <script type="text/javascript">
                    var CountPageThuongHieu = <?php echo ($CountPage - 1); ?>;
                </script>
                <div class="pagine_container" id="pagine-thuong-hieu">
                    <span style="cursor: pointer"class="prev-container">
                        <span class="first"onclick="CurrentPageThuongHieu = 1;
                        changePage('thiet-ke', CurrentPageThuongHieu, CountPageThuongHieu);">Trang đầu</span>
                        <span class="pre"onclick="CurrentPageThuongHieu--;
                        changePage('thiet-ke', CurrentPageThuongHieu, CountPageThuongHieu);">Trước</span>
                    </span>
                    <span class="page-container">
                        <?php
                        for ($i = 1; $i < $CountPage; $i++) {
                            ?>
                            <span class="<?php if ($i === 1) echo 'current-page' ?> number"style="cursor: pointer"><?php echo $i ?></span>
                            <?php
                        }
                        ?>
                    </span>
                    <span style="cursor: pointer"class="next-container">
                        <span class="next" onclick="CurrentPageThuongHieu++;
                        changePage('thiet-ke', CurrentPageThuongHieu, CountPageThuongHieu);">Sau</span>
                        <span class="last"onclick="CurrentPageThuongHieu = CountPageThuongHieu;
                        changePage('thiet-ke', CurrentPageThuongHieu, CountPageThuongHieu);">Trang cuối</span>
                    </span>
                </div>
            </div>
            <div class="left-container-content" id="quang-cao"> 

                <?php
                $CountPost = 0;
                $CountPage = 1;
                $CurrentPage = 1;
                $CountTotalPost = 0;
                foreach ($Category7 as $post) : setup_postdata($post);
                    global $more;
                    $more = 0;
                    if ($CountPost === 0) {
                        ?>
                        <div class="quang-cao-page-container"style='<?php if ($CountPage !== 1) echo 'display:none' ?>'id="quang-cao-page<?php echo $CountPage; ?>">
                            <?php
                        }
                        ?>
                        <div class="content_container">
                            <?php
                            if ($CountPost === 0) {
                                ?>
                                <div class="thumbnail-content">
                                    <?php
                                    if (has_post_thumbnail()) {
                                        the_post_thumbnail();
                                    }
                                    ?>
                                    <span class="content-title"><p><?php the_title() ?></p></span>
                                    <br/>
                                    <?php the_content(''); ?>
                                    <div class="xemchitiet two"><a href="<?php the_permalink() ?>">Xem chi tiết</a></div>
                                </div>
                                <?php
                            } else {
                                ?>
                                <div class="ex-content">
                                    <ul class="more_link">
                                        <li>
                                            <span><a href="<?php the_permalink() ?>"><span class="content-title"><?php the_title() ?></span></a></span>
                                        </li>
                                    </ul>
                                </div>
                                <?php
                            }
                            ?>
                        </div>
                        <?php
                        $CountPost++;
                        if ($CountPost > 2 || $CountTotalPost >= count($Category7) - 1) {
                            ?>
                        </div>
                        <?php
                        $CountPost = 0;
                        $CountPage++;
                    }
                    $CountTotalPost++;
                endforeach;
                ?>
                <script type="text/javascript">
                    var CountPageQuangCao = <?php echo ($CountPage - 1); ?>;
                </script>
                <div class="pagine_container" id="pagine-quang-cao">
                    <span style="cursor: pointer"class="prev-container">
                        <span class="first"onclick="CurrentPageQuangCao = 1;
                        changePage('thiet-ke', CurrentPageQuangCao, CountPageQuangCao);">Trang đầu</span>
                        <span class="pre"onclick="CurrentPageQuangCao--;
                        changePage('thiet-ke', CurrentPageQuangCao, CountPageQuangCao);">Trước</span>
                    </span>
                    <span class="page-container">
                        <?php
                        for ($i = 1; $i < $CountPage; $i++) {
                            ?>
                            <span class="<?php if ($i === 1) echo 'current-page' ?> number"style="cursor: pointer"><?php echo $i ?></span>
                            <?php
                        }
                        ?>
                    </span>
                    <span style="cursor: pointer"class="next-container">
                        <span class="next" onclick="CurrentPageQuangCao++;
                        changePage('thiet-ke', CurrentPageQuangCao, CountPageQuangCao);">Sau</span>
                        <span class="last"onclick="CurrentPageQuangCao = CountPageQuangCao;
                        changePage('thiet-ke', CurrentPageQuangCao, CountPageQuangCao);">Trang cuối</span>
                    </span>
                </div>
            </div>
        </div>
    </div>
    <!--/.left-->
    <div class="right">
        <img style="margin-top: 10px;"src="images/banner290200.jpg" alt="" width="290" height="200" />
    </div><!--/.right-->
    <div class="clear"></div>
    <div class="border_bottom_2"></div>
    <?php
    $Category1Info = get_category(7);
    $args = array('posts_per_page' => 10, 'offset' => 0, 'category' => 7, 'orderby' => 'post_date', 'order' => 'ASC');
    $Category1 = get_posts($args);
    $Category2Info = get_category(9);
    $args = array('posts_per_page' => -1, 'offset' => 0, 'category' => 9, 'orderby' => 'post_date', 'order' => 'ASC');
    $Category2 = get_posts($args);
    $Category3Info = get_category(15);
    $args = array('posts_per_page' => -1, 'offset' => 0, 'category' => 15, 'orderby' => 'post_date', 'order' => 'ASC');
    $Category3 = get_posts($args);
    $Category4Info = get_category(10);
    $args = array('posts_per_page' => -1, 'offset' => 0, 'category' => 10, 'orderby' => 'post_date', 'order' => 'ASC');
    $Category4 = get_posts($args);
    ?>
    <div class="left">
        <div class="menu_bottom">
            <div class="item">
                <h4><?php echo $Category1Info->cat_name ?></h4>
                <ul>
                    <?php
                    foreach ($Category1 as $post) : setup_postdata($post);
                        ?>
                        <li>
                            <a href="<?php the_permalink() ?>"><?php the_title() ?></a>
                        </li>
                    <?php endforeach; ?>
                </ul>
                <h4><?php echo $Category2Info->cat_name ?></h4>
                <ul>
                    <?php
                    foreach ($Category2 as $post) : setup_postdata($post);
                        ?>
                        <li>
                            <a href="<?php the_permalink() ?>"><?php the_title() ?></a>
                        </li>
                    <?php endforeach; ?>
                </ul>
            </div>
            <div class="item">
                <h4><?php echo $Category3Info->cat_name ?></h4>
                <ul>
                    <?php
                    foreach ($Category3 as $post) : setup_postdata($post);
                        ?>
                        <li>
                            <a href="<?php the_permalink() ?>"><?php the_title() ?></a>
                        </li>
                    <?php endforeach; ?>
                </ul>
            </div>
            <div class="item">
                <h4><?php echo $Category4Info->cat_name ?></h4>
                <ul>
                    <?php
                    foreach ($Category4 as $post) : setup_postdata($post);
                        ?>
                        <li>
                            <a href="<?php the_permalink() ?>"><?php the_title() ?></a>
                        </li>
                    <?php endforeach; ?>
                </ul>
            </div>
            <div class="item"></div>
            <div class="item"></div>
        </div>
    </div><!--/.left-->
    <div class="right">
        <div class="follow">
            <div class="twitter"><a href="https://twitter.com/">Follow us on Twitter</a></div>
            <div class="fb"><a href="http://facebook.com">Become our fan<br /> on Facebook</a></div>
            <div class="in"><a href="http://www.linkedin.com">Connect with us<br /> on linkedln</a></div>
        </div><!--/.follow-->
        <!-- contact form -->
        <?php
        $contact = get_post(233);
        echo do_shortcode($contact->post_content);
        ?>
        <!-- end contact form -->
    </div><!--/.right-->
    <div class="clear"></div>
</div>
<?php //get_sidebar();           ?>
<?php get_footer(); ?>